package com.example.controller;

import com.example.pojo.Result;
import com.example.pojo.equTestListPojo;
import com.example.pojo.equipmentManagementPojo;
import com.example.pojo.equipmentTechnologyPojo;
import com.example.service.equipmentManagementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.text.Position;
import java.util.List;
import java.util.Map;

/**
 * ClassName:equipmentManagementControlle
 * Description:
 *是用在《工装管理》中
 * @Author 赵永峰
 * @Create 2024/9/22 23:02
 * @Version 1.0
 */
@RestController
@Slf4j
public class equipmentManagementController {
    @Autowired
    private equipmentManagementService equipmentManagementService;
    //插入一行《工装台账》（工装台账）
    @PostMapping("/equipmentManagementInsert")
    public Result equipmentManagementInsert(@RequestBody equipmentManagementPojo equipmentManagementPojo){
        equipmentManagementService.insertOne(equipmentManagementPojo);
        return Result.success("保存成功");
    }
    //查询树形导航结构,查询的是存放部位不重复，并且按照要求排序的,接收的是两个字段的字段名称。形成一个树形导航的数组（工装台账）
    @PostMapping("/equipmentManagementTreePosition")
    public Result equipmentManagementTreePosition(@RequestBody Map<String,Object> parameters){
        List<equipmentManagementPojo> differentByOne=equipmentManagementService.queryDifferentByOne(parameters);
        return Result.success(differentByOne);
    }
    //根据传来的车间名称，存放位置，查询数据（工装台账）
    @PostMapping("/equipmentManagementSelectClampData")
    public Result equipmentManagementSelectClampData(@RequestBody Map<String,Object> map){
        List<equipmentManagementPojo> equipmentManagementPojoList=equipmentManagementService.SelectClampData(map);
        return Result.success(equipmentManagementPojoList);
    }
    //根据Id修改数据（工装台账）
    @PostMapping("/equipmentManagementInsertEdit")
    public Result equipmentManagementInsertEdit(@RequestBody equipmentManagementPojo equipmentManagementPojo){
        equipmentManagementService.editOne(equipmentManagementPojo);
        return Result.success(equipmentManagementPojo);
    }
    //插入一行（工装技术条件）
    @PostMapping("/equipmentTechnologyInsert")
    public Result equipmentTechnologyInsert(@RequestBody equipmentTechnologyPojo equipmentTechnologyPojo){
        equipmentManagementService.technologyInsertOne(equipmentTechnologyPojo);
        return Result.success("插入成功");
    }
    //查询树形导航结构,查询的是存放部位不重复，并且按照要求排序的,接收的是两个字段的字段名称。形成一个树形导航的数组（工装技术条件）
    @PostMapping("/equipmentTechnologyTreePosition")
    public Result equipmentTechnologyTreePosition(@RequestBody Map<String,Object> parameters){
        List<equipmentTechnologyPojo> differentByOne=equipmentManagementService.queryTechnologyDifferentByOne(parameters);
        return Result.success(differentByOne);
    }
    //根据传来的车间名称，存放位置，查询数据（工装技术条件）
    @PostMapping("/equipmentManagementSelectTechnologyData")
    public Result equipmentManagementSelectTechnologyData(@RequestBody Map<String,Object> map){
        List<equipmentTechnologyPojo> equipmentTechnologyList=equipmentManagementService.SelectTechnologyData(map);
        return Result.success(equipmentTechnologyList);
    }
    //根据Id修改数据（工装技术条件）
    @PostMapping("equipmentTechnologyEdit")
    public Result equipmentTechnologyEdit(@RequestBody equipmentTechnologyPojo equipmentTechnologyPojo){
        equipmentManagementService.editTechnologyOne(equipmentTechnologyPojo);
        return Result.success(equipmentTechnologyPojo);
    }
    //向工装检测数据中插入一行检测数据
    @PostMapping("/equTestInsertOne")
    public Result equTestInsertOne(@RequestBody equTestListPojo equTestListPojo){
        equipmentManagementService.equTestInsertOne(equTestListPojo);
        return Result.success();
    }
    //查询最后检测的一条数据
    @PostMapping("/equLastTimeTest")
    public Result equLastTimeTest(@RequestBody equTestListPojo equTestListPojo){
        equTestListPojo equTest=equipmentManagementService.equLastTimeTest(equTestListPojo);
        return Result.success(equTest);
    }
}
